var can1;
var can2;
 
var ctx1;
var ctx2;

var canWidth;
var canHeight;

var lastTime;
var deltaTime;

var bgPic = new Image();


document.body.onload = game;

function game() {
  // console.log('onload');
  init();
  lastTime = Date.now();
  deltaTime = 0;
  gameloop();
}

function init() {
  // 获得场景 或者canvas context
  can1 = document.getElementById("canvas1");// fishes，dust， UI，circle
  ctx1 = can1.getContext('2d');
  can2 = document.getElementById("canvas2");// bg, ane, fruist
  ctx2 = can2.getContext('2d');

  bgPic.src = "./src/background.jpg";

  canWidth = can1.width;
  canHeight = can1.height;

}

function gameloop() {
  window.requestAnimFrame(gameloop);// setInterval, setTimeout, frame per second
  // console.log('gameloop');
  var now = Date.now();
  deltaTime = now - lastTime;
  lastTime = now;
  // console.log(deltaTime);

  drawBackground();
}